<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>show_time (lib/SleepMirror.rb)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/SleepMirror.rb, line 158</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">show_time</span> (<span class="ruby-identifier">event</span>)
  <span class="ruby-identifier">elapsed_time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">$t</span>
  <span class="ruby-identifier">$answered</span> = <span class="ruby-keyword kw">true</span>
  <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Elapased time #{elapsed_time}s&quot;</span>
  <span class="ruby-constant">TTF</span>.<span class="ruby-identifier">setup</span>()
  <span class="ruby-identifier">ttfont_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-keyword kw">__FILE__</span>),<span class="ruby-value str">&quot;FreeSans.ttf&quot;</span>)
  <span class="ruby-identifier">ttfont</span> = <span class="ruby-constant">TTF</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">ttfont_path</span>, <span class="ruby-value">24</span> )
  <span class="ruby-identifier">result</span> = <span class="ruby-identifier">ttfont</span>.<span class="ruby-identifier">render</span>( <span class="ruby-node">&quot;You chose #{event.key.upcase}; that is #{event.key==:f ? &quot;Correct!&quot; : &quot;incorrect.&quot;} Your time was #{elapsed_time}s.  Press Q or ESC to quit.&quot;</span>, <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">:white</span> )
  <span class="ruby-identifier">result</span>.<span class="ruby-identifier">blit</span>( <span class="ruby-identifier">$screen</span>,[<span class="ruby-identifier">$image</span>.<span class="ruby-identifier">size</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">/</span><span class="ruby-value">2</span><span class="ruby-operator">-</span><span class="ruby-identifier">result</span>.<span class="ruby-identifier">size</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">/</span><span class="ruby-value">2</span>,<span class="ruby-identifier">$image</span>.<span class="ruby-identifier">size</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">/</span><span class="ruby-value">2</span>])
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>
